//
//  YoungHisCell.m
//  youthNote
//
//  Created by huangrensheng on 15/12/30.
//  Copyright © 2015年 laber. All rights reserved.
//

#import "YoungHisCell.h"

@implementation YoungHisCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initChildViews];
        [self makeConstraints];
    }
    return self;
}

- (void)initChildViews{
    self.iconNameView = [[UIView alloc] init];
    [self.contentView addSubview:self.iconNameView];
    
    self.icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_icon"]];
    [self.iconNameView addSubview:self.icon];
    
    self.useName = [[UILabel alloc] initWithFont:[UIFont systemFontOfSize:FONT_LITTLE_MIDDLE] TextColor:GRAYISH_COLOR Text:@"你好，叫什么"];
    [self.iconNameView addSubview:self.useName];
    
    self.content = [[UILabel alloc] initWithFont:[UIFont systemFontOfSize:FONT_SMALL] TextColor:GRAYISH_COLOR Text:@"此外，新的条例将原来的独生子女母亲产假调整为奖励假30天。这意味着，凡符合法律法规规定生育的，不论是生育一孩、还是二孩，以及符合法律法规规定再生育的，都可以享受增加30天产假的优待。同时，丈夫的陪产假从10天增加到15天。"];
    self.content.numberOfLines = 0;
    [self.contentView addSubview:self.content];
    
    self.showImage = [[UIView alloc] init];
    self.showImage.backgroundColor = GRAYISH_COLOR;
    [self.contentView addSubview:self.showImage];
    
    self.goodBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.goodBtn.selected = YES;
    [self.goodBtn setImage:[UIImage imageNamed:@"good"] forState:UIControlStateNormal];
    [self.goodBtn setImage:[UIImage imageNamed:@"good_selected"] forState:UIControlStateSelected];
    [self.goodBtn setImageEdgeInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
    [self.contentView addSubview:self.goodBtn];
    
    self.goodCount = [[UILabel alloc] initWithFont:[UIFont systemFontOfSize:FONT_LITTLE] TextColor:GRAYISH_COLOR Text:@"10"];
    [self.contentView addSubview:self.goodCount];
    
    self.share = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.share setImage:[UIImage imageNamed:@"share"] forState:UIControlStateNormal];
    [self.share setImageEdgeInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
    [self.contentView addSubview:self.share];
    
}

- (void)makeConstraints{
    typeof(self) __weak weakSelf = self;
    
    [self.iconNameView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@50);
        make.leading.and.trailing.equalTo(weakSelf.contentView);
        make.top.equalTo(weakSelf.contentView.mas_top);
    }];
    
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.iconNameView.mas_centerY);
        make.leading.equalTo(weakSelf.iconNameView.mas_leading).equalTo(@8);
        make.height.equalTo(@35);
        make.width.equalTo(@35);
    }];
    
    [self.useName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.iconNameView.mas_centerY);
        make.leading.equalTo(weakSelf.icon.mas_trailing).equalTo(@8);
        make.trailing.equalTo(weakSelf.iconNameView.mas_trailing).equalTo(@(-8));
    }];
    
    [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.iconNameView.mas_bottom);
        make.trailing.equalTo(weakSelf.contentView.mas_trailing).equalTo(@(-8));
        make.leading.equalTo(weakSelf.contentView.mas_leading).equalTo(@8);
    }];
    
    [self.showImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.content.mas_bottom).equalTo(@8);
        make.trailing.equalTo(weakSelf.contentView.mas_trailing).equalTo(@(-8));
        make.leading.equalTo(weakSelf.contentView.mas_leading).equalTo(@8);
    }];
    
    [self.goodBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.showImage.mas_bottom).equalTo(@(-5));
        make.leading.equalTo(weakSelf.icon.mas_leading);
        make.height.equalTo(@40);
        make.width.equalTo(@40);
        make.bottom.equalTo(weakSelf.contentView.mas_bottom);
    }];
    
    [self.goodCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(weakSelf.goodBtn.mas_trailing).equalTo(@(-5));
        make.centerY.equalTo(weakSelf.goodBtn.mas_centerY);
    }];
    
    [self.share mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(weakSelf.contentView.mas_trailing).equalTo(@(-8));
        make.height.equalTo(@40);
        make.width.equalTo(@40);
        make.bottom.equalTo(weakSelf.contentView.mas_bottom);
    }];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
